package org.example.d7_collection_nesting;

import java.util.*;

/**
 * 目标：理解集合的嵌套
 */
public class Test {
    public static void main(String[] args) {
        //1.定义一个map集合用于存储全部的省份信息 何其对应的城市信息
        Map<String, List<String>> map = new HashMap<>();

        List<String> cities1 = new ArrayList<>();
        Collections.addAll(cities1,"南京市","扬州市","苏州市","无锡市","常州市");
        map.put("江苏省",cities1);

        List<String> cities2 = new ArrayList<>();
        Collections.addAll(cities2,"武汉市","孝感市","十堰市","宜昌市","鄂州市");
        map.put("湖北省",cities2);

        List<String> cities3 = new ArrayList<>();
        Collections.addAll(cities3,"石家庄市","唐山市","邢台市","保定市","张家口市");
        map.put("河北省",cities3);
        System.out.println(map);

        //根据湖北省这键获取对应的值
        //方法一
        List<String> cities = map.get("湖北省");
        for (String city : cities) {
            System.out.println(city);
        }
        //方法二
        map.forEach((p,c)->{
            System.out.println(p + "----->" + c);
        });
    }
}
